package cn.wangyu.mo.controller;

import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author wy
 * @date 2021/4/4 15:41
 */
@Api("userController api列表")
@RestController
public class UserController {

    @ApiOperation(value = "查询所有信息",notes = "查询数据库中某个学生的信息")
    @GetMapping(value = "/queryAll")
    public List<String> queryAll() throws Exception {
        List<String> data=new ArrayList<String>();
        data.add("java134");
        data.add("java资料社区");
        return data;
    }

    @ApiOperation(value="获取redis中数据", notes="通过key值获取")
    @ApiResponses({
            @ApiResponse(code=400,message = "请求报文存在语法错误"),
            @ApiResponse(code=401,message = "发送的请求需要有通过 HTTP 认证的认证信息"),
            @ApiResponse(code=403,message = "请求资源的访问被服务器拒绝"),
            @ApiResponse(code=404,message="服务器上没有找到请求的资源")
    })
    @ApiImplicitParam(name = "key", value = "redis键值", required = true, dataType = "String")
    @PostMapping(value = "/getRedis")
    public String getRedis(String key) throws Exception {
        Map<String,String> data=new HashMap<String,String>();
        data.put("123","Java资料社区");
        data.put("321","Java");
        data.put("132","小编");
        return  data.get(key);
    }

    @ApiIgnore
    @RequestMapping("/index")
    public String index()  {
        return "ApiIgnore=忽略这个接口";
    }
}
